package com.vhall.component.controller.preparation;

import com.vhall.component.entity.preparation.dto.*;
import com.vhall.component.entity.preparation.vo.*;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.enums.OperateTypeEnum;
import com.vhall.component.service.annotation.OperateLog;
import com.vhall.component.service.preparation.AdmWatermarkService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 水印管理-admin端
 *
 * @author xing.wang
 * @date 2022/10/27
 */
@RestController
@RequestMapping("/v4/watermark/admin")
@Tag(name = "水印管理-管理端")
@RequiredArgsConstructor
public class AdmWatermarkController {
    private final AdmWatermarkService admWatermarkService;

    /**
     * 水印模板管理获取列表
     *
     * @param vo 参数
     * @return PageVO<AdmWatermarkListDTO>
     */
    @GetMapping("/list")
    @TokenAuth("sys:watermark:list")
    public List<AdmWatermarkListDTO> list(@Validated WatermarkListVO vo) {
        return admWatermarkService.getWatermarkList(vo);
    }

    /**
     * 创建水印模板
     *
     * @param vo 参数
     * @return AdmWatermarkCreateDTO
     */
    @PostMapping("/create")
    @TokenAuth("sys:watermark:create")
    @OperateLog(type = OperateTypeEnum.CREATE, name = "创建水印模板")
    public AdmWatermarkCreateDTO create(@Validated AdmWatermarkCreateVO vo) {
        return admWatermarkService.createWatermark(vo);
    }

    /**
     * 更新水印模板
     *
     * @param vo 参数
     * @return AdmWatermarkUpdateDTO
     */
    @PostMapping("/update")
    @TokenAuth("sys:watermark:update")
    @OperateLog(type = OperateTypeEnum.UPDATE, name = "更新水印模板")
    public AdmWatermarkUpdateDTO update(@Validated AdmWatermarkUpdateVO vo) {
        return admWatermarkService.updateWatermark(vo);
    }

    /**
     * 删除水印模板
     *
     * @param vo 参数
     * @return AdmWatermarkDeleteDTO
     */
    @PostMapping("/delete")
    @TokenAuth("sys:watermark:delete")
    @OperateLog(type = OperateTypeEnum.DELETE, name = "删除水印模板")
    public AdmWatermarkDeleteDTO delete(@Validated AdmWatermarkDeleteVO vo) {
        return admWatermarkService.deleteWatermark(vo);
    }

    /**
     * 设置平台默认水印
     *
     * @param vo 参数
     * @return AdmWatermarkSetDefaultDTO
     */
    @PostMapping("/default-watermark")
    @TokenAuth("sys:watermark:default")
    @OperateLog(type = OperateTypeEnum.UPDATE, name = "设置平台默认水印")
    public AdmWatermarkSetDefaultDTO defaultWatermark(@Validated AdmWatermarkSetDefaultVO vo) {
        return admWatermarkService.defaultWatermark(vo);
    }
}
